import React,{ Component } from "react";
import {BrowserRouter ,Route} from 'react-router-dom'
import App from '../App'
import Login from '../views/Login'
import Admin from '../views/Admin'
import ContentMain from '../components/ContentMain'
class Routers extends Component{
    render(){
        return(
            <>
            <BrowserRouter>
                <App>
                    <Route path="/"  render={
                        ()=>
                            <Route path="/" component={Login} exact></Route>
                    }>

                    </Route>
                    <Route path="/login"  render={
                        ()=>
                            <Route path="/login" component={Login} exact></Route>
                    }>

                    </Route>
                    {/*   除登录页外，其他页面路由需以admin/xxxxx 进行匹配   注释为例子参考  */}
                    <Route path="/admin" render={
                        ()=>
                        <Admin>
                            <Route path="/admin" component={ContentMain} exact></Route>
                            {/* <Route exact path='/admin/AloneTable' component={global.AloneTable}/>
                            <Route exact path='/admin/general/fromDemo' component={global.FromDemo}/>
                            <Route exact path='/admin/AlertDemo' component={global.Alert}/>
                            <Route exact path='/admin/TableDemo' component={global.Table}/>
                            <Route exact path='/admin/HttpDemo' component={global.HttpDemo}/>
                            <Route exact path='/admin/TreeDemo' component={global.TreeDemo}/> */}
                            {
                                global.menus.map((item)=>{
                                    return(
                                        <Route exact path={item.key} key={item.key} component={global[item.routerType]}/>
                                    )
                                })
                            }
                        </Admin>
                    }></Route>
                </App>
            </BrowserRouter>
            </>
        )
    }
}
export default Routers